package com.atguigu.gmall.task;

import com.atguigu.gmall.rabbit.constant.RabbitConst;
import com.atguigu.gmall.rabbit.service.RabbitService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

@Component
@EnableScheduling
@Slf4j
public class ScheduledTask {

    @Autowired
    private RabbitService rabbitService;
    @Scheduled(cron = "0 0 0 * * ? *")
    public void task1(){
        rabbitService.sendMessage(RabbitConst.EXCHANGE_DIRECT_TASK,RabbitConst.ROUTING_TASK_1,"");
    }

    @Scheduled(cron = "0 0 18 * * ?")
    public void task18() {
        log.info("task18");
        rabbitService.sendMessage(RabbitConst.EXCHANGE_DIRECT_TASK, RabbitConst.ROUTING_TASK_18, "");
    }

}
